package com.jcl.cloud.services.unicrawler.common.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisCommands;
import redis.clients.jedis.JedisPool;

public class JedisUtil {


    public static JedisCommands getJedisCommands(JedisCluster jedisCluster, JedisPool jedisPool){
         if(null != jedisCluster){
             return jedisCluster;
         }else if(null != jedisPool){
             return  jedisPool.getResource();
         }
         return  null;
    }


    public static void releaseJedisConnection(JedisCommands jedisCommands){
        try {
            Jedis jedis = (Jedis)jedisCommands;
            jedis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
